﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using buildingLib.xcategory;
using DocPrinter;

namespace _dmis.xcategory
{
    public partial class ItemPrintPreview : Form
    {
        public XIOTicket ticket;
        public ItemPrintPreview()
        {
            InitializeComponent();
        }

        private void ItemPrintPreview_Load(object sender, EventArgs e)
        {
            ItemPrinter.PrintTicket(this.CreateGraphics(), ticket);
        }

        private void ItemPrintPreview_Paint(object sender, PaintEventArgs e)
        {
            ItemPrinter.PrintTicket(this.CreateGraphics(), ticket);
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnPrint_Click(object sender, EventArgs e)
        {
            this.print_Dlg.Document = print_Doc;
            if (print_Dlg.ShowDialog(this) == DialogResult.OK)
            {
                print_Doc.Print();
                this.Close();
            }
        }

        private void print_Doc_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            ItemPrinter.PrintTicket(e.Graphics, ticket);
        }
    }
}